package practice;

import java.util.Random;
import java.util.Scanner;

public class FingerFlashing {
    public static void main(String[] args) {
        Scanner stdIn = new Scanner(System.in);
        Random random = new Random();
        String[] s = new String[]{
                "石头", "剪刀", "布"};

        int retry;
        do {

            int comp1 = random.nextInt(3);
            int player;


            do {
                System.out.print("石头剪刀布：");
                for (int i = 0; i < s.length; i++) {
                    System.out.printf("(%d)%s", i, s[i]);
                }
                System.out.print(": ");
                player = stdIn.nextInt();
            } while (player < 0 || player > 2);

            System.out.println("我出" + s[player] + ", 电脑出" + s[comp1] + ".");

            int judge = (player - comp1 + 3) % 3;
            switch (judge) {
                case 0:
                    System.out.println("平局");
                    break;
                case 1:
                    System.out.println("电脑赢了");
                    break;
                case 2:
                    System.out.println("我赢了");
                    break;

            }
            System.out.println("再来一次？ (0)否  (1)是");
                retry=stdIn.nextInt();


        } while (retry==1);

    }
}